package com.atguigu.realtime.gmallsugar.mapper;

import com.atguigu.realtime.gmallsugar.bean.C3;
import com.atguigu.realtime.gmallsugar.bean.Spu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @Author lzc
 * @Date 2022/4/26 14:37
 */
public interface ProductMapper {

    @Select("SELECT sum(order_amount)\n" +
        "FROM product_stats_2022\n" +
        "WHERE toYYYYMMDD(stt) = #{date}\n")
    public abstract BigDecimal gmv(@Param("date") int date);  // 20220326
    
    
    @Select("SELECT\n" +
        "    tm_name,\n" +
        "    sum(order_amount) AS order_amount\n" +
        "FROM product_stats_2022\n" +
        "WHERE toYYYYMMDD(stt) = #{date}\n" +
        "GROUP BY tm_name\n")
   List<Map<String, Object>> gmvByTm(@Param("date") int date);  // 20220326
    
    
    @Select("\n" +
        "SELECT\n" +
        "    category3_name,\n" +
        "    sum(order_amount) AS order_amount\n" +
        "FROM product_stats_2022\n" +
        "WHERE toYYYYMMDD(stt) = #{date}\n" +
        "GROUP BY category3_name\n")
   List<C3> gmvByC3(@Param("date") int date);  // 20220326
    
    @Select("SELECT\n" +
        "    spu_name,\n" +
        "    sum(order_amount) AS order_amount\n" +
        "FROM product_stats_2022\n" +
        "WHERE toYYYYMMDD(stt) =#{date} \n" +
        "GROUP BY spu_name\n")
   List<Spu> gmvBySpu(@Param("date") int date);  // 20220326

}
